package com.zlq.cn.util;

import cn.hutool.core.codec.Base64;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;

import java.io.ByteArrayInputStream;
import java.security.PublicKey;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.interfaces.ECPublicKey;

/**
 * @author zhoucl
 * @date 2023年05月25日 15:08
 */
@Slf4j
public class JWTUtils {
    public static void main(String[] args) {
        String xx = "{\"signedPayload\":\"eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWFQb1BsZHZwU29FSDBsQnJqRFB2OWpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjFkR2h2Y21sMGVURUxNQWtHQTFVRUN3d0NSell4RXpBUkJnTlZCQW9NQ2tGd2NHeGxJRWx1WXk0eEN6QUpCZ05WQkFZVEFsVlRNQjRYRFRJeE1EZ3lOVEF5TlRBek5Gb1hEVEl6TURreU5EQXlOVEF6TTFvd2daSXhRREErQmdOVkJBTU1OMUJ5YjJRZ1JVTkRJRTFoWXlCQmNIQWdVM1J2Y21VZ1lXNWtJR2xVZFc1bGN5QlRkRzl5WlNCU1pXTmxhWEIwSUZOcFoyNXBibWN4TERBcUJnTlZCQXNNSTBGd2NHeGxJRmR2Y214a2QybGtaU0JFWlhabGJHOXdaWElnVW1Wc1lYUnBiMjV6TVJNd0VRWURWUVFLREFwQmNIQnNaU0JKYm1NdU1Rc3dDUVlEVlFRR0V3SlZVekJaTUJNR0J5cUdTTTQ5QWdFR0NDcUdTTTQ5QXdFSEEwSUFCT29UY2FQY3BlaXBOTDllUT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jJURlZoWjAwMlFtZEVOVFpMZVV0QlBUMGlYWDAuZXlKdmNtbG5hVzVoYkZSeVlXNXpZV04wYVc5dVNXUWlPaUl5TURBd01EQXdNemszTWpRM01qRTVJaXdpWVhWMGIxSmxibVYzVUhKdlpIVmpkRWxrSWpvaVkyOXRMbVo1TG5SbGMzUXVkMlZsYXlJc0luQnliMlIxWTNSSlpDSTZJbU52YlM1bWVTNTBaWE4wTG5kbFpXc2lMQ0poZFhSdlVtVnVaWGRUZEdGMGRYTWlPakVzSW5OcFoyNWxaRVJoZEdVaU9qRTJPVEk0TlRnd01UWXlNek1zSW1WdWRtbHliMjV0Wlc1MElqb2lVMkZ1WkdKdmVDSXNJbkpsWTJWdWRGTjFZbk5qY21sd2RHbHZibE4wWVhKMFJHRjBaU0k2TVRZNU1qZzFPREF3T0RBd01Dd2ljbVZ1WlhkaGJFUmhkR1VpT2pFMk9USTROVGd4TWpnd01EQjkuRGh1b295SDgteG5pbTF1c096cXZTcW9LWTdLbUpDX1BHcllNdFU4UzBuLUNuRTEtLWdwYVpTWG1nOEZzMEtXY1JPSUpfZjZUbEpXc2QxRkFWdlUtOFEiLCJzdGF0dXMiOjF9LCJ2ZXJzaW9uIjoiMi4wIiwic2lnbmVkRGF0ZSI6MTY5Mjg1ODAxNjI0MH0.RjcESLfuEp4JsnthrCuK-6g0MnsmfOel_qYMa0_kb9STJKIQ9bZXSyaXLArmGHqGI4YMxFsFCzxVwL2dGQoblw\"}";
        JSONObject param = JSON.parseObject(xx);
        String signedPayload = JWTUtils.verify(param.getString("signedPayload"));
        if (StringUtils.isNotEmpty(signedPayload)) {
            JSONObject signedPayloadJson = JSONObject.parseObject(Base64.decodeStr(signedPayload));
            String notificationType = signedPayloadJson.getString("notificationType");
            String subtype = signedPayloadJson.getString("subtype");
            String signedTransactionInfo = signedPayloadJson.getJSONObject("data").getString("signedTransactionInfo");
            JSONObject transactionInfo = JSON.parseObject(Base64.decodeStr(verify(signedTransactionInfo)));
            System.out.println(notificationType);
            System.out.println(subtype);
            System.out.println(transactionInfo);
        }
    }

    public static String verify(String jwt) {
        try {
            // 拿到 header 中 x5c 数组中第一个
            DecodedJWT decodedJWT = JWT.decode(jwt);
            String header = new String(java.util.Base64.getDecoder().decode(decodedJWT.getHeader()));
            String x5c0 = JSONObject.parseArray(JSONObject.parseObject(header).get("x5c").toString()).get(0).toString();
            // 获取公钥
            PublicKey publicKey = getPublicKeyByX5c(x5c0);
            // 验证 token
            Algorithm algorithm = Algorithm.ECDSA256((ECPublicKey) publicKey, null);
            algorithm.verify(decodedJWT);
            return decodedJWT.getPayload();
        } catch (Exception e) {

        }
        return null;
    }

    public static PublicKey getPublicKeyByX5c(String x5c) throws CertificateException {
        byte[] x5c0Bytes = java.util.Base64.getDecoder().decode(x5c);
        CertificateFactory fact = CertificateFactory.getInstance("X.509");
        X509Certificate cer = (X509Certificate) fact.generateCertificate(new ByteArrayInputStream(x5c0Bytes));
        return cer.getPublicKey();
    }
}
